{include file="common/header"}
<div id="app" v-cloak>
    <div class="el-pane-warp">
        <el-form ref="ruleForm" :rules="rules" :model="config" label-width="150px">
            <el-form-item label="代码编辑路径：" prop="path">
                <el-input v-model="config.path"></el-input>
            </el-form-item>
        </el-form>
        <div class="el-bottom" style="width: 100%">
            <el-button 
                :loading="loading"
                type="primary" 
                size="medium" 
                icon="el-icon-refresh-right"
                @click="save()">
                保 存
            </el-button>
        </div>
    </div>
</div>
<script>
new Vue({
    el: '#app',
    data() {
        return {
            config: {:json_encode($config)},
            loading: false,
            updateUrl: "code/config/index",
            rules: {
                path: [
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
            },
        }
    },
    methods: {
        /**
         * 保存数据
         */
        save() {
            let self = this;
            self.$refs.ruleForm.validate((valid) => {
                if (valid) {
                    self.loading = true;
                    request.post(self.updateUrl, {value: self.config}, function(res){
                        self.loading = false;
                        self.$notify({showClose: true, message: res.message, type: res.status});
                    });
                } else {
                    return false;
                }
            });
        },
    },
})
</script>
{include file="common/footer"}